package com.aplink.generic.pojo;

import java.util.ArrayList;

public class JoinCol extends ArrayList<Object> {
    private static final long serialVersionUID = - 4781397631662920945L;

    public void AddJoin( String FrontJoin, String BackJoin, String JoinOn ) {
        JoinInfo join = new JoinInfo();
        join.FrontJoin = FrontJoin;
        join.BackJoin = BackJoin;
        join.JoinOn = JoinOn;
        this.add( join );
    }

    public String GetJoinString() {
        StringBuilder sb = new StringBuilder();
        JoinInfo join;
        for ( int temp = 0 ; temp < this.size() ; temp++ ) {
            join = (JoinInfo) this.get( temp );
            if ( temp == 0 ) {
                sb.append( join.FrontJoin + " inner join " + join.BackJoin
                        + " on " + join.JoinOn );
            } else {
                sb.append( " inner join " + join.BackJoin + " on " + join.JoinOn );
            }
        }
        return sb.toString();
    }
}
